package com.cll.pmis.common;

import lombok.Data;

import java.io.Serializable;

/**
 * @author chenliangliang
 * @date 2018/6/18
 */
@Data
public class Result implements Serializable {

    private static final long serialVersionUID = -7880114087099301266L;

    private boolean flag;
    private String msg;
    private Object data;

    public Result(boolean flag, String msg, Object data) {
        this.flag = flag;
        this.msg = msg;
        this.data = data;
    }


    public static Result success(String msg,Object data){
        return new Result(true,msg,data);
    }

    public static Result ok(Object data){
        return success("OK",data);
    }

    public static Result fail(String msg){
        return new Result(false,msg,"");
    }


    public static Result insertError(){
        return fail("插入数据异常");
    }

    public static Result selectError(){
        return fail("查询数据异常");
    }

    public static Result updateError(){
        return fail("更新数据异常");
    }

    public static Result deleteError(){
        return fail("删除数据异常");
    }

    public static Result paramError(){
        return fail("参数异常");
    }

    public static Result paramError(String info){
        return fail("参数异常: "+info);
    }
}
